<!-- 审核微博 -->
<script setup>
import { ref, onMounted } from 'vue'
import { apiCommentShowListByWeibo, apiWeiboUpdateState } from '@/api/admin.js'
import warningSvg from '@/assets/icons/warning.svg'
import arrowSvg from '@/assets/icons/arrow.svg'
import { ElMessage } from 'element-plus';
const weiboList = ref()
const getData = async () => {
  const res = await apiCommentShowListByWeibo(1, 1000, '', 3)
  weiboList.value = res.data.data.records
}
const load = () => {
  // 动态加载，想优化可以写
}
onMounted(() => {
  getData()
})
const banWeiboEvent = async id => {
  const res = await apiWeiboUpdateState({
    weiboId: id,
    state: -1
  })
  ElMessage.success('封禁成功')
  getData()
}
const arrowWeiboEvent = async id => {
  const res = await apiWeiboUpdateState({
    weiboId: id,
    state: 1
  })
  ElMessage.success('审批通过')
  getData()
}
</script>
<template>
  <ul
    v-infinite-scroll="load"
    class="infinite-list"
    style="overflow: auto; width: 1200px; margin-top: 90px"
  >
    <li v-for="item in weiboList" :key="item.weiboId" style="margin-top: 20px">
      <div class="container">
        <div class="header">
          <div class="imageIn">
            <img
              :src="item.img"
              alt=""
              style="height: 50px; width: 50px; border-radius: 50%"
            />
          </div>
          <div style="display: flex; flex-direction: column; width: 950px">
            <div style="font-size: 20px">
              {{ item.title }}
            </div>
            <div>
              {{ item.createTime }}
            </div>
          </div>
          <img
            :src="arrowSvg"
            alt=""
            style="height: 50px; cursor: pointer"
            @click="arrowWeiboEvent(item.weiboId)"
          />
          <img
            :src="warningSvg"
            alt=""
            style="height: 50px; cursor: pointer"
            @click="banWeiboEvent(item.weiboId)"
          />
        </div>
        <div class="textBody">
          {{ item.content }}
        </div>
      </div>
    </li>
  </ul>
</template>
<style lang="scss" scoped>
.textBody {
  background-color: rgb(255, 255, 255);
  height: 120px;
  width: 1000px;
  margin: 10px 0px 10px 80px;
  font-size: 18px;
  padding: 3px;
}
.imageIn {
  height: 50px;
  width: 50px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.header {
  width: 1150px;
  margin-top: 5px;
  display: flex;
  height: 50px;
  background-color: rgb(241, 241, 241);
  border-bottom: 1px solid #ccc;
  align-items: center;
}
.container {
  height: 200px;
  width: 1200px;
  background-color: rgb(241, 241, 241);
  display: flex;
  flex-direction: column;
}
</style>
